home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / simula / books / books.lha / kirkerud / histo2.sim < prev    next >
Text File  |  1993-08-16  |  1KB  |  40 lines

  1. begin
  2.  
  3.   integer least_weight_group,  greatest_weight_group;
  4.   
  5.   outtext("Type the least and greatest weight-group "
  6.           "containing measurements: "); 
  7.   breakoutimage; inimage;
  8.   least_weight_group := inint;  greatest_weight_group := inint;
  9.  
  10.   begin
  11.     
  12.     integer array count(least_weight_group : greatest_weight_group);
  13.     integer weight_group, asterisk_number, number_of_asterisks;
  14.     real    weight;
  15.   
  16.   ! Read the measurements one by one:   ;
  17.        outtext(" Please type the weights. "); outimage;
  18.        outtext(" Remember to type -1 after the last one!");  outimage;
  19.      weight := inreal;
  20.      while  weight ge 0 do
  21.      begin
  22.        weight_group := entier(weight);
  23.        count(weight_group) := count(weight_group) + 1;
  24.        weight := inreal;
  25.      end;
  26.   
  27.   ! Write the histogram:   ;
  28.      outtext("Weight : Number of children"); outimage;
  29.      for weight_group := least_weight_group step 1  until greatest_weight_group do
  30.        begin
  31.          outint(weight_group, 6); outtext(" : ");
  32.          number_of_asterisks := count(weight_group);
  33.          for asterisk_number := 1 step 1  until number_of_asterisks do outchar('*');
  34.          outimage;
  35.        end weight_group-repetition;
  36.  
  37.   end of block with declaration of the count-array;
  38.  
  39. end of program;
  40.